package com.probiz.estore.common.model.catalog.base;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.catalog.GiftCategory;
import com.probiz.estore.core.model.BaseObject;

/**
 * GiftCategory Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class GiftCategoryTbl extends BaseObject implements Serializable {

    protected Integer categoryId;
	protected Integer parentId;
	protected Short categoryType;
	protected String categoryCode;
	protected String categoryName;
	protected String categoryDescription;
	protected Short depth;
	protected Short hasChildren;
	protected String parentPath;
	protected String categoryPath;
	protected String imageUrl;
	protected Integer sortOrder;
	protected Short status;
	protected String displayFlag;
	protected Integer itemCount;
	protected Integer activeItemCount;
	protected Integer createBy;
	protected Integer updateBy;
	protected java.util.Date createTime;
	protected java.util.Date updateTime;
	protected Integer version;
	protected GiftCategory	parent;
	
	protected Set			gifts		= new HashSet();
	protected Set			children	= new HashSet();

	public Set getChildren() {
		return children;
	}

	public void setChildren(Set children) {
		this.children = children;
	}
	
	/**
	 * Default Empty Constructor for class GiftCategory
	 */
	public GiftCategoryTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class GiftCategory
	 */
	public GiftCategoryTbl (
		 Integer in_categoryId
        ) {
		this.setCategoryId(in_categoryId);
    }


	public java.util.Set getGifts () {
		return gifts;
	}	
	
	public void setGifts (java.util.Set in_gifts) {
		this.gifts = in_gifts;
	}
    
	/**
	 * 	 * @return Integer
     * @hibernate.id column="categoryId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getCategoryId() {
		return this.categoryId;
	}
	
	/**
	 * Set the categoryId
	 */	
	public void setCategoryId(Integer aValue) {
		this.categoryId = aValue;
	}	

	/**
	 * 父目录id	 * @return Integer
	 * @hibernate.property column="parentId" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getParentId() {
		return this.getParent() == null ? null : this.getParent()
				.getCategoryId();
	}
	
	/**
	 * Set the parentId
	 */	
	public void setParentId(Integer aValue) {
		if (aValue == null) {
			parent = null;
		} else {
			parent = new GiftCategory(aValue);
			parent.setVersion(Integer.valueOf(0));// set a version to cheat
			// hibernate only
		}
	}	

	/**
	 * 无用，暂时保留	 * @return Short
	 * @hibernate.property column="categoryType" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getCategoryType() {
		return this.categoryType;
	}
	
	/**
	 * Set the categoryType
	 */	
	public void setCategoryType(Short aValue) {
		this.categoryType = aValue;
	}	

	/**
	 * 目录编码，ak，主要用于url生成。	 * @return String
	 * @hibernate.property column="categoryCode" type="java.lang.String" length="32" not-null="true" unique="false"
	 */
	public String getCategoryCode() {
		return this.categoryCode;
	}
	
	/**
	 * Set the categoryCode
	 * @spring.validator type="required"
	 */	
	public void setCategoryCode(String aValue) {
		this.categoryCode = aValue;
	}	

	/**
	 * 目录名称	 * @return String
	 * @hibernate.property column="categoryName" type="java.lang.String" length="128" not-null="true" unique="false"
	 */
	public String getCategoryName() {
		return this.categoryName;
	}
	
	/**
	 * Set the categoryName
	 * @spring.validator type="required"
	 */	
	public void setCategoryName(String aValue) {
		this.categoryName = aValue;
	}	

	/**
	 * 目录描述	 * @return String
	 * @hibernate.property column="categoryDescription" type="java.lang.String" length="65535" not-null="false" unique="false"
	 */
	public String getCategoryDescription() {
		return this.categoryDescription;
	}
	
	/**
	 * Set the categoryDescription
	 */	
	public void setCategoryDescription(String aValue) {
		this.categoryDescription = aValue;
	}	

	/**
	 * 深度	 * @return Short
	 * @hibernate.property column="depth" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getDepth() {
		return this.depth;
	}
	
	/**
	 * Set the depth
	 */	
	public void setDepth(Short aValue) {
		this.depth = aValue;
	}	

	/**
	 * 是否有子目录
            1=有
            0=无	 * @return Short
	 * @hibernate.property column="hasChildren" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getHasChildren() {
		return this.hasChildren;
	}
	
	/**
	 * Set the hasChildren
	 */	
	public void setHasChildren(Short aValue) {
		this.hasChildren = aValue;
	}	

	/**
	 * 祖先目录路径，例如1.5 表示nokia目录的祖先目录结构路径是： 商品根目录->手机目录	 * @return String
	 * @hibernate.property column="parentPath" type="java.lang.String" length="32" not-null="true" unique="false"
	 */
	public String getParentPath() {
		return this.parentPath;
	}
	
	/**
	 * Set the parentPath
	 * @spring.validator type="required"
	 */	
	public void setParentPath(String aValue) {
		this.parentPath = aValue;
	}	

	/**
	 * 自身目录路径，例如1.5.8. 表示诺基亚目录的结构路径是： 商品根目录->手机目录->诺基亚目录。最后的8是诺基亚目录的主键。	 * @return String
	 * @hibernate.property column="categoryPath" type="java.lang.String" length="32" not-null="true" unique="false"
	 */
	public String getCategoryPath() {
		return this.categoryPath;
	}
	
	/**
	 * Set the categoryPath
	 * @spring.validator type="required"
	 */	
	public void setCategoryPath(String aValue) {
		this.categoryPath = aValue;
	}	

	/**
	 * 图片url	 * @return String
	 * @hibernate.property column="imageUrl" type="java.lang.String" length="255" not-null="false" unique="false"
	 */
	public String getImageUrl() {
		return this.imageUrl;
	}
	
	/**
	 * Set the imageUrl
	 */	
	public void setImageUrl(String aValue) {
		this.imageUrl = aValue;
	}	

	/**
	 * 排序值，一般值越小，越靠前	 * @return Integer
	 * @hibernate.property column="sortOrder" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getSortOrder() {
		return this.sortOrder;
	}
	
	/**
	 * Set the sortOrder
	 * @spring.validator type="required"
	 */	
	public void setSortOrder(Integer aValue) {
		this.sortOrder = aValue;
	}	

	/**
	 * 0=前台不可见
            1=前台可见	 * @return Short
	 * @hibernate.property column="status" type="java.lang.Short" length="5" not-null="true" unique="false"
	 */
	public Short getStatus() {
		return this.status;
	}
	
	/**
	 * Set the status
	 * @spring.validator type="required"
	 */	
	public void setStatus(Short aValue) {
		this.status = aValue;
	}	

	/**
	 * 自定义的显示标志0=标签页、1= new、2= hot可出现多个，如 0,2,   1,2,	 * @return String
	 * @hibernate.property column="displayFlag" type="java.lang.String" length="32" not-null="false" unique="false"
	 */
	public String getDisplayFlag() {
		return this.displayFlag;
	}
	
	/**
	 * Set the displayFlag
	 */	
	public void setDisplayFlag(String aValue) {
		this.displayFlag = aValue;
	}	

	/**
	 * 目录下的商品的数量	 * @return Integer
	 * @hibernate.property column="itemCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getItemCount() {
		return this.itemCount;
	}
	
	/**
	 * Set the itemCount
	 */	
	public void setItemCount(Integer aValue) {
		this.itemCount = aValue;
	}	

	/**
	 * 前台可见礼品个数	 * @return Integer
	 * @hibernate.property column="activeItemCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getActiveItemCount() {
		return this.activeItemCount;
	}
	
	/**
	 * Set the activeItemCount
	 */	
	public void setActiveItemCount(Integer aValue) {
		this.activeItemCount = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="createBy" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getCreateBy() {
		return this.createBy;
	}
	
	/**
	 * Set the createBy
	 */	
	public void setCreateBy(Integer aValue) {
		this.createBy = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="updateBy" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getUpdateBy() {
		return this.updateBy;
	}
	
	/**
	 * Set the updateBy
	 */	
	public void setUpdateBy(Integer aValue) {
		this.updateBy = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="createTime" type="java.util.Date" length="19" not-null="true" unique="false"
	 */
	public java.util.Date getCreateTime() {
		return this.createTime;
	}
	
	/**
	 * Set the createTime
	 * @spring.validator type="required"
	 */	
	public void setCreateTime(java.util.Date aValue) {
		this.createTime = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="updateTime" type="java.util.Date" length="19" not-null="true" unique="false"
	 */
	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}
	
	/**
	 * Set the updateTime
	 * @spring.validator type="required"
	 */	
	public void setUpdateTime(java.util.Date aValue) {
		this.updateTime = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="version" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getVersion() {
		return this.version;
	}
	
	/**
	 * Set the version
	 * @spring.validator type="required"
	 */	
	public void setVersion(Integer aValue) {
		this.version = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof GiftCategoryTbl)) {
			return false;
		}
		GiftCategoryTbl rhs = (GiftCategoryTbl) object;
		return new EqualsBuilder()
				.append(this.categoryId, rhs.categoryId)
				.append(this.parentId, rhs.parentId)
				.append(this.categoryType, rhs.categoryType)
				.append(this.categoryCode, rhs.categoryCode)
				.append(this.categoryName, rhs.categoryName)
				.append(this.categoryDescription, rhs.categoryDescription)
				.append(this.depth, rhs.depth)
				.append(this.hasChildren, rhs.hasChildren)
				.append(this.parentPath, rhs.parentPath)
				.append(this.categoryPath, rhs.categoryPath)
				.append(this.imageUrl, rhs.imageUrl)
				.append(this.sortOrder, rhs.sortOrder)
				.append(this.status, rhs.status)
				.append(this.displayFlag, rhs.displayFlag)
				.append(this.itemCount, rhs.itemCount)
				.append(this.activeItemCount, rhs.activeItemCount)
				.append(this.createBy, rhs.createBy)
				.append(this.updateBy, rhs.updateBy)
				.append(this.createTime, rhs.createTime)
				.append(this.updateTime, rhs.updateTime)
				.append(this.version, rhs.version)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.categoryId) 
				.append(this.parentId) 
				.append(this.categoryType) 
				.append(this.categoryCode) 
				.append(this.categoryName) 
				.append(this.categoryDescription) 
				.append(this.depth) 
				.append(this.hasChildren) 
				.append(this.parentPath) 
				.append(this.categoryPath) 
				.append(this.imageUrl) 
				.append(this.sortOrder) 
				.append(this.status) 
				.append(this.displayFlag) 
				.append(this.itemCount) 
				.append(this.activeItemCount) 
				.append(this.createBy) 
				.append(this.updateBy) 
				.append(this.createTime) 
				.append(this.updateTime) 
				.append(this.version) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("categoryId", this.categoryId) 
				.append("parentId", this.parentId) 
				.append("categoryType", this.categoryType) 
				.append("categoryCode", this.categoryCode) 
				.append("categoryName", this.categoryName) 
				.append("categoryDescription", this.categoryDescription) 
				.append("depth", this.depth) 
				.append("hasChildren", this.hasChildren) 
				.append("parentPath", this.parentPath) 
				.append("categoryPath", this.categoryPath) 
				.append("imageUrl", this.imageUrl) 
				.append("sortOrder", this.sortOrder) 
				.append("status", this.status) 
				.append("displayFlag", this.displayFlag) 
				.append("itemCount", this.itemCount) 
				.append("activeItemCount", this.activeItemCount) 
				.append("createBy", this.createBy) 
				.append("updateBy", this.updateBy) 
				.append("createTime", this.createTime) 
				.append("updateTime", this.updateTime) 
				.append("version", this.version) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "categoryId";
	}
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return categoryId;
	}
	
	public GiftCategory getParent() {
		return parent;
	}

	public void setParent(GiftCategory parent) {
		this.parent = parent;
	}
	
}